#ifndef DEFINES_H
#define DEFINES_H

#define _USE_MATH_DEFINES
#define FPS 60

const float TIMESTEP = 1./FPS;

#define WIN_X 800
#define WIN_Y 600
#define WIN_X_HALF 400
#define WIN_Y_HALF 300
#define WIN_X_OFF 15
#define WIN_Y_OFF 15
#define FOV 60

#define VOXEL_SIZE 1

#define WORLD_SIZE 256

#define WORLD_XSIZE 256
#define WORLD_YSIZE 128
#define WORLD_ZSIZE 256

#define CHUNK_SIZE 16
#define CHUNK_PWR 4

#define MAX_CHUNKS 2048

#define X_CHUNKS 16
#define Y_CHUNKS 8
#define Z_CHUNKS 16

#define X_CHUNKS_PWR 4
#define Y_CHUNKS_PWR 3
#define Z_CHUNKS_PWR 4

#define MOD_CHNKSIZE(a) ((a)&(CHUNK_SIZE-1))// n mod CHUNK_SIZE
#define DIV_CHNKSIZE(a) ((a)>>CHUNK_PWR)// n div CHUNK_SIZE
#define MUL_CHNKSIZE(a) ((a)<<CHUNK_PWR)
#define MUL_XCHNK(a)((a)<<X_CHUNKS_PWR)
#define MUL_YCHNK(a)((a)<<Y_CHUNKS_PWR)
#define MUL_ZCHNK(a)((a)<<Z_CHUNKS_PWR)
//#define VECTOR_TO_INDEX(x,y,z) (MUL_CHNKSIZE(MUL_CHNKSIZE(MOD_CHNKSIZE(x))) + MUL_CHNKSIZE(MOD_CHNKSIZE(y)) + MOD_CHNKSIZE(z))

#define MARCH_LIMIT 256
#define FLOOR(a) ((int)(a))
#define TO_RAD(a) ((a)*(M_PI/180.))
#define TO_ANGLE(a) ((a)*(180./M_PI))

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define CLAMP(n,a,b) MIN(MAX(n,a),b)

//#define BUFFER_OFFSET(b,i) (((char*)(b)) + (i))
#define BUFFER_OFFSET(bytes) ((GLubyte*) NULL + (bytes))
enum bits{TOP=1,BOTTOM=2,LEFT=4,RIGHT=8,FRONT=16,BACK=32,DRAW=64};


typedef unsigned char uchar;

#define MAX_SHADER 10

#define GET_INT_SIGN(x) ( 1 | ( (x) >> (sizeof(int) * 8 - 1) ) )
#define PRINT(format,b) printf(#b "=%" #format "\n",b)

#define v3f vector3<float>
#define v3i vector3<int>

#define REND RenderManager::getInstance()
#define GENG GameEngine::getInstance()

#define MAX_GAME_ELEMENT_HEIGHT 2

#define SQRT2 1.414214
#define SQRT3 1.732051
#define SQRT_THIRD 0.577350

#endif // DEFINES_H
